<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg" style="background-color: white;">
     <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				 <button onclick="backPlan()" type="button" class="btn btn-primary">返回计划列表</button>
				<form id="formId" th:object="${plan}">
					<!-- 隐藏div保存大计划id -->
					<div style="display: none;" id ="planIdDiv" th:text="${plan.iD}">
					</div>
					<div class="select-list" style="">
						<ul>
							<li>
								小计划状态：<select name="sTATUS" th:with="type=${@dict.getType('plan_item_status')}">
									<option value="">所有</option>
									<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
								</select>
							</li>
							<li class="select-time">
								<label>执行时间： </label>
								<input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[doBeginTime]"/>
								<span>-</span>
								<input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[doEndTime]"/>
							</li>
							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
	        <!-- <div class="btn-group-sm hidden-xs" id="toolbar" role="group">
				<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:hatchetPlanItem:add">
					<i class="fa fa-plus"></i> 添加
				</a>
				<a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()" shiro:hasPermission="system:hatchetPlanItem:edit">
					<i class="fa fa-edit"></i> 修改
				</a>
				<a class="btn btn-danger btn-del btn-del disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:hatchetPlanItem:remove">
					<i class="fa fa-remove"></i> 删除
				</a>
				<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:hatchetPlanItem:export">
						<i class="fa fa-download"></i> 导出
				 </a>
			</div> -->
			<br><br>
			<table style="width: 100%;margin-top: 40px">
					<tr>
						<td width="100%">
							<div  id ="planProgress" style="width: 100%;">
							</div>
						</td>
					</tr>
					<tr></tr>
			</table>
			<div>
			
			
			</div>
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
        //状态数据查询字典表显示
        var sTATUS = [[${@dict.getType('plan_item_status')}]];
        //明细类型 （还款/养卡）
        var tYPE = [[${@dict.getType('plan_item_type')}]];
        var prefix = ctx + "system/hatchetPlanItemForDLS";
        $(function() {
        	initPlanProgress();//初始化计划进度
            var options = {
                url: prefix + "/listForJLR?planId="+$("#planIdDiv").text(),//把大计划id作为条件传到后端
                /* createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
				exportUrl: prefix + "/export", */
                modalName: "还款计划明细",
				search: false, 
		       showExport: false,
                columns: [{
		            checkbox: true
		        },
				{
		        	field : 'id',
					title : '计划明细ID',
					visible: false
				},
				/* {
					field : 'merchantNo', 
					title : '用户账号',
					sortable: false
				},  */
				{
					field : 'merchantName', 
					title : '用户名称',
					sortable: false
				},
				/* {
					field : 'planId', 
					title : '大计划ID',
					sortable: false
				}, */
				{
					field : 'fromBankAccount', 
					title : '银行卡号',
					sortable: false
				},
				{
					field : 'fromBankAccountName', 
					title : '持卡人',
					sortable: false
				},
				{
					field : 'fromBankphone', 
					title : '预留手机',
					sortable: false
				},
				{
					field : 'money', 
					title : '付款金额(元)',
					sortable: true
				},
				{
					field : 'type', 
					title : '类型',
					align: 'center',
					formatter: function(value, item, index) {
						if(item.groupNumber=="-1"){
							return "<b>退款</b>";
						}
						if(value =="sale"){
							return "<b>交易</b>";
						} else if(value =="payment") {
							return "<b>还款</b>";
						}
			            }
				},
				{
					field : 'status', 
					title : '状态',
					align: 'center',
					formatter: function(value, item, index) {
			            	return $.table.selectDictLabel(sTATUS, item.status);
			            }
				},
				{
					field : 'acqResponseCode', 
					title : '终端返回码',
					sortable: false
				},
				{
					field : 'planTime', 
					title : '执行时间',
					sortable: true
				},
				{
					field : 'toMoney', 
					title : '到款金额(元)',
					sortable: true
				}
				/* ,
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
		            	actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.iD + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.iD + '\')"><i class="fa fa-remove"></i>删除</a>');
						return actions.join('');
		            }
		        } */]
            };
            $.table.init(options);
        });
        
      //初始化计划进度
    	function initPlanProgress(){
            $.ajax({
 		        url:prefix+"/getPlanProgress", //请求后台
 		        type: "POST",
 		       	data:	{
 		       	"planId":$("#planIdDiv").text()
 		       	},
 		        success:function(re){
 		        	if(re.status=="SUCCESS"){
 		        		var value = re.progress;
 	 		        	var str ='';
 					  	str += '<div class="progress progress-striped" data-percent="'+value+'%" style="margin:auto;background-color: #eeeeee;">'
 					    str += '<div class="progress-bar progress-bar-info" style="width:'+value+'%;color:white;">';
 					    str += '<span class="percent" >'+value+'</span>%';
 					    str += '</div>';
 					    str += '</div>';
 					    $("#planProgress").append(str);
 		        	}
	            }
 		    });
    	}
    	
    	function backPlan(){
			window.location.href=ctx+'system/hatchetPlanForDLS/JLR';
		}
    </script>
</body>
</html>